Skip to main content

Medias

MetadataViews.Medias

Medias MetadataView returns the following:

  • items: Array
    • file: struct
      • url: String
    • mediaType: String
import AllDay from 0xALLDAYADDRESS
import MetadataViews from 0xMETADATAVIEWSADDRESS

pub fun main(address: Address, id: UInt64): MetadataViews.Medias {
let account = getAccount(address)

let collectionRef = account.getCapability(AllDay.CollectionPublicPath)
.borrow<&{AllDay.MomentNFTCollectionPublic}>()
?? panic("Could not borrow capability from public collection")

let nft = collectionRef.borrowMomentNFT(id: id)
?? panic("Couldn't borrow momentNFT")

return nft.resolveView(Type<MetadataViews.Medias>())! as! MetadataViews.Medias
}